import {$request} from '../../utils/request'

// 请求订单数据
export const getOrderDetail = ((id) => {
    return new Promise((resolve, reject) => {
        $request({
            url: 'getorder/' +id + '/',
            method: 'GET'
        }).then((res) => {
            // console.log("请求订单数据成功", res);
            resolve(res);
        }).catch((err) => {
            console.log("请求订单数据失败", err);
            reject(err);
        });
    });
});


// 点击完成订单
export const orderFinish = ((id) => {
    return new Promise((resolve, reject) => {
        $request({
            url: 'orderfinish/' +id + '/',
            method: 'POST'
        }).then((res) => {
            // console.log("请求订单数据成功", res);
            wx.showToast({
                title: '操作成功!',
              })
            setTimeout(() => {
                 wx.reLaunch({
                   url: '../orderList/orderList',
                 })

            },1000)
            resolve(res);
        }).catch((err) => {
            console.log("点击完成订单操作", err);
            wx.showToast({
                title: '操作失败!',
                icon:'error'
              })
            setTimeout(() => {
                 wx.reLaunch({
                   url: '../orderList/orderList',
                 })

            },1000)
            reject(err);
        });
    });
});